package com.wj.tool.common.bean.restful;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class RestfulResponseBody<T> implements Serializable {
    private static final long serialVersionUID = 2097609128603129250L;
    private int code;
    private String message;
    private ResponseErrors.ErrorNode[] errors;
    private T data;

    public RestfulResponseBody() {
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public ResponseErrors.ErrorNode[] getErrors() {
        return this.errors;
    }

    public void setErrors(ResponseErrors.ErrorNode[] errors) {
        this.errors = errors;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            RestfulResponseBody<?> that = (RestfulResponseBody)o;
            return this.code == that.code && Objects.equals(this.message, that.message) && Objects.equals(this.data, that.data);
        } else {
            return false;
        }
    }

    public int hashCode() {
        return Objects.hash(new Object[]{this.code, this.message, this.data});
    }

    public String toString() {
        return "RestfulResponseBody{code=" + this.code + ", message='" + this.message + '\'' + ", errors=" + Arrays.toString(this.errors) + ", data=" + this.data + '}';
    }
}